package com.bw.home

import com.bw.home.entity.CollectEntity
import com.bw.home.entity.CommentEntity
import com.bw.home.entity.LoginEntity
import com.bw.home.entity.SimpleTypeEntity
import com.bw.home.entity.SimpleVideoEntity
import com.bw.lib_net.BaseRes
import kotlinx.coroutines.flow.Flow
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.PUT
import retrofit2.http.Query

interface ApiService {
    //获取类型
    @GET("/videotype/getSimpleType")
    fun getSimpleType(): Flow<BaseRes<List<SimpleTypeEntity>>>

    //获取数据
    @GET("/videosimple/getSimpleVideoByChannelId")
    fun getSimpleVideo(
        @Query("channelId") id: String,
        @Query("page") page: Int,
        @Query("pagesize") size: Int
    ): Flow<BaseRes<List<SimpleVideoEntity>>>


    //猜您喜欢
    @GET("/videosimple/getRecommendSimpleVideo")
    fun getRecommendSimpleVideo(
        @Query("page") page: Int,
        @Query("pagesize") size: Int
    ): Flow<BaseRes<List<SimpleVideoEntity>>>


    //获取评论
    @GET("/comment/getCommentByUserId")
    fun getComment(
        @Query("datatype") type: Int,
        @Query("itemid") id: String
    ): Flow<BaseRes<List<CommentEntity>>>

    //收藏
    @POST("/collection/collection")
    fun getCollect(@Body entity: CollectEntity): Flow<BaseRes<CollectEntity>>

    //取消收藏
    @DELETE("/collection/unCollection")
    fun unCollect(@Body entity: CollectEntity): Flow<BaseRes<CollectEntity>>

    //登录
    @POST("/user/login")
    fun login(
        @Query("username") username: String,
        @Query("password") password: String
    ): Flow<BaseRes<LoginEntity>>

    //注册
    @POST("/user/register")
    fun register(
        @Query("username") username: String,
        @Query("password") password: String
    ): Flow<BaseRes<LoginEntity>>

    //修改密码
    @PUT("/user/modifyPwd")
    fun updatePassword(
        @Query("userid") userId: Int,
        @Query("newPwd") newPassword: String
    ): Flow<BaseRes<Boolean>>
}